package com.wangsd.web.shop.mapper;

import com.gitee.fastmybatis.core.mapper.CrudMapper;
import com.wangsd.web.shop.entity.Coupon;
import com.wangsd.web.shop.entity.Customer;
import org.apache.ibatis.annotations.Update;

public interface CouponMapper extends CrudMapper<Coupon, Long> {

    @Update("update coupon set distributed_coupons = distributed_coupons + 1 where id = #{id} and distributed_coupons < max_coupons")
    void updateDistributedCoupons(Long id);

    @Update("update coupon set distributed_coupons = distributed_coupons - 1 where id = #{id}")
    void updateDistributedCouponsSub(Long id);
}
